/**
 * 用户相关的请求模块
 */
import request from '@/utils/request'

export const login = (data)=>{
	return request({
		url:'/mp/v1_0/authorizations',
		data,
		method:'POST'
	})
}
export const sendMs = (phone)=>{
	return request({
		url:`/mp/v1_0/captchas/${phone}`,
		method:'GET'
	})
}
export const getUserInfo = ()=>{
	return request({
		url:'/app/v1_0/user',
		method:'GET'
	})
}
export const getUserChannels = ()=>{
	return request({
		url:'/app/v1_0/user/channels',
		method:'GET'
	})
}
export const followUser = userId=>{
	return request({
		url:'/app/v1_0/user/followings',
		method:'POST',
		data:{
			target:userId
		}
	})
}
export const unFollowUser = userId=>{
	return request({
		url:`/app/v1_0/user/followings/${userId}`,
		method:'DELETE'
	})
}
export const collected= artId=>{
	return request({
		url:'/app/v1_0/article/collections',
		method:'POST',
		data:{
			target:artId
		}
	})
}
export const uncollected = artId=>{
	return request({
		url:`/app/v1_0/article/collections/${artId}`,
		method:'DELETE'
	})
}
// 对文章点赞或取消点赞
export const like = artId=>{
	return request({
		url:'/app/v1_0/article/likings',
		method:'POST',
		data:{
			target:artId
		}
	})
}
export const unlike = artId=>{
	return request({
		url:`/app/v1_0/article/likings/${artId}`,
		method:'DELETE'
	})
}
// 对评论点赞或取消点赞
export const commentLike = commentId =>{
	return request({
		url:'/app/v1_0/comment/likings',
		method:'POST',
		data:{
			target:commentId
		}
	})
}
export const unCommentLike = commentId =>{
	return request({
		url:`/app/v1_0/comment/likings/${commentId}`,
		method:'DELETE'
	})
}
/* 
	获取用户个人资料
 */
export const getUserProfile = ()=>{
	return request({
		url:'/app/v1_0/user/profile',
		method:'GET'
	})
}
// 修改用户个人资料
export const updateUserProfile = (params)=>{
	return request({
		url:'/app/v1_0/user/profile',
		method:'PATCH',
		data:params
	})
}
// 修改用户头像
export const upDateUserAvatar = data=>{
	return request({
		url:'/app/v1_0/user/photo',
		method:'PATCH',
		data
	})
}